<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>css弹出效果</title>
  <link rel="stylesheet" href="global.css">
  <style>
    body {
      font-family: Arial, sans-serif;
      background: url(./imges/popup-bg.png) no-repeat;
      backdrop-filter: blur(2px);
      /* 此时会保持图像的纵横比并将图像缩放成将完全覆盖背景定位区域的最小大小 */
      background-size: cover;
      /* vh/vw:视口（即你在浏览器中看到的部分页面）单位 1vh等于视口高度的1%*/
      height: 100vh;
    }

    h1 {
      text-align: center;
      font-family: Tahoma, Arial, sans-serif;
      color: #06D85F;
      margin: 80px 0;
    }

    .box {
      width: 40%;
      margin: 0 auto;
      padding: 35px;
      background: rgba(255, 255, 255, 0.2);
      border: 2px solid #fff;
      border-radius: 20px/50px;
      text-align: center;
      /* background-clip: 设置元素的背景（背景图片或颜色）是否延伸到边框、内边距盒子、内容盒子下面*/
      /* padding-box:背景延伸至内边距（padding）外沿 不会绘制到边框处 */
      background-clip: padding-box;
    }

    .button {
      font-size: 1em;
      padding: 10px;
      color: #fff;
      border: 2px solid #06D85F;
      border-radius: 20px/50px;
      text-decoration: none;
      cursor: pointer;
      transition: all 0.3s ease-out;
    }

    .button:hover {
      background: #06D85F;
    }

    /* 实现遮罩效果并带延时动画 */
    .overlay {
      position: fixed;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      background: rgba(0, 0, 0, 0.7);
      transition: opacity 500ms;
      visibility: hidden;
      opacity: 0;
    }

    /* :target CSS 伪类 代表一个唯一的页面元素(目标元素)，其id 与当前URL片段匹配  */
    .overlay:target {
      visibility: visible;
      opacity: 1;
    }

    .popup {
      position: relative;
      width: 30%;
      margin: 70px auto;
      padding: 20px;
      background: #fff;
      border-radius: 5px;
      transition: all 5s ease-in-out;
    }

    .popup h2 {
      margin-top: 0;
      color: #333;
      font-family: Tahoma, Arial, sans-serif;
    }

    .popup .close {
      position: absolute;
      top: 20px;
      right: 30px;
      transition: all 200ms;
      font-size: 30px;
      font-weight: bold;
      text-decoration: none;
      color: #333;
    }

    .popup .close:hover {
      color: #06D85F;
    }

    .popup .content {
      max-height: 30%;
      overflow: auto;
    }

    /* 屏幕宽带低于700像素 弹出框的宽度占比变大为70% */
    @media screen and (max-width: 700px) {
      .box {
        width: 70%;
      }

      .popup {
        width: 70%;
      }

      h1 {
        font-size: 20px;
      }
    }
  </style>
</head>

<body>
  <header>
    <a href="https://codepen.io/imprakash/pen/GgNMXO">出自：https://codepen.io/imprakash/pen/GgNMXO</a>
  </header>

  <h1>不带JavaScript的弹出/模态窗口</h1>
  <div class="box">
    <a class="button" href="#popup1">点击弹出窗口</a>
  </div>

  <div id="popup1" class="overlay">
    <div class="popup">
      <h2>我是弹出窗口</h2>
      <a class="close" href="#">&times;</a>
      <div class="content">
        这里是内容区域。。。。。。。。
      </div>
    </div>
  </div>
</body>